package com.hsogoo.ultraman.controller;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hsogoo.ultraman.service.ConfigManageService;
import com.hsogoo.ultraman.service.ConfigServer;

@Slf4j
@RestController
@RequestMapping("/configManage")
public class ConfigManageController {

    @Autowired
    private ConfigManageService configManageService;
    @Autowired
    private ConfigServer configServer;

    @GetMapping("/findAllEnv")
    public String test(){
        return "test ok";
    }

    @GetMapping("publishConfig/{env}/{app}/{namespace}")
    public void publishConfig(@PathVariable String env, @PathVariable String app, @PathVariable String namespace){
        log.info("[env={}],[app={}],[namespace={}]", env, app, namespace);
        configManageService.publishConfig();
        configServer.notifyPublish(env, app, namespace);
    }
}
